package com.iteye.cwh.monitor.service.impl;

import java.util.Arrays;
import java.util.List;
import com.iteye.cwh.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iteye.cwh.monitor.mapper.IotProjectMapper;
import com.iteye.cwh.monitor.domain.IotProject;
import com.iteye.cwh.monitor.service.IIotProjectService;

/**
 * 项目Service业务层处理
 * 
 * @author chenweihua
 * @date 2024-04-29
 */
@Service
public class IotProjectServiceImpl implements IIotProjectService 
{
    @Autowired
    private IotProjectMapper iotProjectMapper;

    /**
     * 查询项目
     * 
     * @param projectId 项目主键
     * @return 项目
     */
    @Override
    public IotProject selectIotProjectByProjectId(Long projectId)
    {
        return iotProjectMapper.selectById(projectId);
    }

    /**
     * 查询项目列表
     * 
     * @param iotProject 项目
     * @return 项目
     */
    @Override
    public List<IotProject> selectIotProjectList(IotProject iotProject)
    {
        return iotProjectMapper.selectIotProjectList(iotProject);
    }

    /**
     * 新增项目
     * 
     * @param iotProject 项目
     * @return 结果
     */
    @Override
    public int insertIotProject(IotProject iotProject)
    {
        iotProject.setCreateTime(DateUtils.getNowDate());
        return iotProjectMapper.insert(iotProject);
    }

    /**
     * 修改项目
     * 
     * @param iotProject 项目
     * @return 结果
     */
    @Override
    public int updateIotProject(IotProject iotProject)
    {
        iotProject.setUpdateTime(DateUtils.getNowDate());
        return iotProjectMapper.updateById(iotProject);
    }

    /**
     * 批量删除项目
     * 
     * @param projectIds 需要删除的项目主键
     * @return 结果
     */
    @Override
    public int deleteIotProjectByProjectIds(Long[] projectIds)
    {
        return iotProjectMapper.deleteBatchIds(Arrays.asList(projectIds));
    }

    /**
     * 删除项目信息
     * 
     * @param projectId 项目主键
     * @return 结果
     */
    @Override
    public int deleteIotProjectByProjectId(Long projectId)
    {
        return iotProjectMapper.deleteById(projectId);
    }
}
